home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / MIDI / camd-37.1 / development / include / midi / camd.i < prev    next >
Encoding:
Text File  |  1999-10-27  |  14.0 KB  |  515 lines

  1.     ifnd    MIDI_CAMD_I
  2. MIDI_CAMD_I set 1
  3.  
  4. *************************************************************************
  5. *     C. A. M. D.       (Commodore Amiga MIDI Driver)                   *
  6. *************************************************************************
  7. *                                                                       *
  8. * Design & Development  - Roger B. Dannenberg                           *
  9. *                       - Jean-Christophe Dhellemmes                    *
  10. *                       - Bill Barton                                   *
  11. *                       - Darius Taghavy                                *
  12. *                                                                       *
  13. * Copyright 1990-1999 by Amiga, Inc.                                  *
  14. *                                                                       *
  15. *************************************************************************
  16. *
  17. * camd.i      - General CAMD include files.
  18. *             - General CAMD definitions.
  19. *             - CAMD library functions.
  20. *
  21. *************************************************************************
  22.  
  23.     ifnd    EXEC_TYPES_I
  24.     include "exec/types.i"
  25.     endc
  26.  
  27.     ifnd    EXEC_MACROS_I
  28.     include "exec/macros.i"
  29.     endc
  30.  
  31.     ifnd    EXEC_NODES_I
  32.     include "exec/nodes.i"
  33.     endc
  34.  
  35.     ifnd    UTILITY_TAGITEM_I
  36.     include "utility/tagitem.i"
  37.     endc
  38.  
  39.  
  40. ****************************************************************
  41. *
  42. *   Library Name and Version
  43. *
  44. ****************************************************************
  45.  
  46. CamdName    macro
  47.             dc.b    'camd.library',0
  48.             endm
  49.  
  50. ; CamdVersion equ     2     ; !!! old
  51.  
  52.  
  53. ****************************************************************
  54. *
  55. *   CAMD internal lists that can be locked
  56. *
  57. ****************************************************************
  58.  
  59.     ENUM
  60.     EITEM   CD_Linkages                         ; internal linages
  61.     EITEM   CD_NLocks
  62.  
  63.  
  64.     ifne 0      ; !!! old
  65.  
  66. ****************************************************************
  67. *
  68. *   MIDI Port Definitions
  69. *
  70. *   The default Unit Ports are:
  71. *
  72. *              ports
  73. *       unit  in  out
  74. *       ----  --  ---
  75. *        0     1   0
  76. *        1     3   2
  77. *        2     5   4
  78. *        3     6   5
  79. *
  80. *   User ports are allocated starting at CMP_Max and descending.
  81. *
  82. ****************************************************************
  83.  
  84. CMP_Out     equ 0       ; Default port # of MIDI Output (really (unit) * 2)
  85. CMP_In      equ 1       ; Default port # of MIDI Input (really (unit) * 2 + 1)
  86. CMP_Max     equ 31      ; highest port #
  87.     endc
  88.  
  89.  
  90. ****************************************************************
  91. *
  92. *   MidiMsg
  93. *
  94. ****************************************************************
  95.  
  96.     STRUCTURE MidiMsg,0
  97.         LABEL   mm_Msg
  98.         UBYTE   mm_Status
  99.         UBYTE   mm_Data1
  100.         UBYTE   mm_Data2
  101.         UBYTE   mm_Port
  102.         ULONG   mm_Time
  103.         LABEL   MidiMsg_Size
  104.  
  105.  
  106. ***************************************************************
  107. *
  108. *   MidiCluster -- a meeting place for linkages
  109. *
  110. *   All fields are READ ONLY.  Modifications to fields may
  111. *   performed only through the appropriate library function
  112. *   calls.
  113. *
  114. ***************************************************************
  115.  
  116.     STRUCTURE MidiCluster,LN_SIZE
  117.         WORD    mcl_Pad
  118.         STRUCT  mcl_Receivers,LH_SIZE
  119.         STRUCT  mcl_Senders,LH_SIZE
  120.         WORD    mcl_PublicParticipants
  121.         UWORD   mcl_Flags
  122.         LABEL   MidiCluster_Size
  123.         ; NOTE: Cluster name follows structure, and is pointed to by ln_Name
  124.  
  125. ***************************************************************
  126. *
  127. *   MidiLink -- links a cluster and a MidiNode
  128. *
  129. *   All fields are READ ONLY.  Modifications to fields may
  130. *   performed only through the appropriate library function
  131. *   calls.
  132. *
  133. ***************************************************************
  134.  
  135.     STRUCTURE SysExFilter,0
  136.         LABEL   sxf_Packed
  137.         UBYTE   sxf_Mode                ; mode bits
  138.         STRUCT  sxf_ID,3                ; space for 3 1-byte id's or 1 3-byte id
  139.         LABEL   SysExFilter_Size
  140.  
  141.     STRUCTURE MidiLink,LN_SIZE
  142.         WORD    ml_Pad
  143.         STRUCT  ml_OwnerNode,MLN_SIZE
  144.         APTR    ml_MidiNode
  145.         APTR    ml_Location
  146.         APTR    ml_ClusterComment
  147.         UBYTE   ml_Flags
  148.         UBYTE   ml_PortID
  149.         UWORD   ml_ChannelMask
  150.         ULONG   ml_EventTypeMask
  151.         ULONG   ml_SysExFilter
  152.         APTR    ml_ParserData
  153.         APTR    ml_UserData
  154.         LABEL   MidiLink_Size
  155.  
  156.         ; MidiLink types
  157.     ENUM
  158.     EITEM   MLTYPE_Receiver
  159.     EITEM   MLTYPE_Sender
  160.     EITEM   MLTYPE_NTypes
  161.  
  162.         ; ml_Flags
  163.     BITDEF  ML,SENDER,0                          ; this link sends from app
  164.     BITDEF  ML,PARTCHANGE,1                      ; part change pending
  165.     BITDEF  ML,PRIVATELINK,2                     ; make this link private
  166.     BITDEF  ML,DEVICELINK,3                      ; set by devices only!
  167.  
  168.         ; MidiLink tags
  169.     ENUM    TAG_USER+65
  170.  
  171.     EITEM   MLINK_Location
  172.     EITEM   MLINK_ChannelMask
  173.     EITEM   MLINK_EventMask
  174.     EITEM   MLINK_UserData
  175.     EITEM   MLINK_Comment
  176.     EITEM   MLINK_PortID
  177.     EITEM   MLINK_Private
  178.     EITEM   MLINK_Priority
  179.     EITEM   MLINK_SysExFilter
  180.     EITEM   MLINK_SysExFilterX
  181.     EITEM   MLINK_Parse
  182.     EITEM   MLINK_DeviceLink
  183.     EITEM   MLINK_ErrorCode
  184.     EITEM   MLINK_Name
  185.  
  186.  
  187. ****************************************************************
  188. *
  189. *   MidiNode
  190. *
  191. *   NOTE:  Applications are not permitted to modify this
  192. *   structure directly.  The appropriate library functions must
  193. *   be used for such manipulation.
  194. *
  195. *   Alot of this stuff is camd.library private and may vanish
  196. *   or move!
  197. *
  198. ****************************************************************
  199.  
  200.     STRUCTURE MidiNode,LN_SIZE
  201.         UWORD   mi_ClientType
  202.         APTR    mi_Image
  203.  
  204.         STRUCT  mi_OutLinks,MLH_SIZE
  205.         STRUCT  mi_InLinks,MLH_SIZE
  206.  
  207.         APTR    mi_SigTask
  208.         APTR    mi_ReceiveHook
  209.         APTR    mi_ParticipantHook
  210.         BYTE    mi_ReceiveSigBit
  211.         BYTE    mi_ParticipantSigBit
  212.         UBYTE   mi_ErrFilter
  213.         UBYTE   mi_Alignment
  214.  
  215.         APTR    mi_TimeReference
  216.  
  217.         ULONG   mi_MsgQueueSize         ; size of MsgQueue in MidiMsg's (includes overflow padding)
  218.         ULONG   mi_SysExQueueSize       ; size of SysExQueue in bytes (includes overflow padding)
  219.  
  220.         ; private stuff below here
  221.  
  222.         LABEL   MidiNode_PublicSize
  223.  
  224.         ; client types
  225.  
  226. CCType_Sequencer        equ     (1<<0)
  227. CCType_SampleEditor     equ     (1<<1)
  228. CCType_PatchEditor      equ     (1<<2)
  229. CCType_Notator          equ     (1<<3)
  230. CCType_EventProcessor   equ     (1<<4)
  231. CCType_EventFilter      equ     (1<<5)
  232. CCType_EventRouter      equ     (1<<6)
  233. CCType_ToneGenerator    equ     (1<<7)
  234. CCType_EventGenerator   equ     (1<<8)
  235. CCType_GraphicAnimator  equ     (1<<9)
  236.  
  237.         ; Tags for CreateMidi() and SetMidiAttrs()
  238.     ENUM    TAG_USER+65
  239.  
  240.     EITEM   MIDI_Name
  241.     EITEM   MIDI_SignalTask
  242.     EITEM   MIDI_RecvHook
  243.     EITEM   MIDI_PartHook
  244.     EITEM   MIDI_RecvSignal
  245.     EITEM   MIDI_PartSignal
  246.     EITEM   MIDI_BufferSize
  247.     EITEM   MIDI_SysExSize
  248.     EITEM   MIDI_TimeStamp
  249.     EITEM   MIDI_ErrFilter
  250.     EITEM   MIDI_ClientType
  251.     EITEM   MIDI_Image
  252.     EITEM   MIDI_ErrorCode
  253.  
  254.  
  255. ****************************************************************
  256. *
  257. *   MidiNode tag items for use with CreateMidi().
  258. *
  259. ****************************************************************
  260.  
  261.         ifne    0
  262.     ENUM    TAG_USER+64
  263.  
  264.     EITEM   CMA_SysEx       ; int - allocate a sys/ex buffer,
  265.                             ; ti_Data specifies size in bytes.
  266.                             ; Default is 0.  Only valid if
  267.                             ; RecvSize is non-zero. */
  268.  
  269.     EITEM   CMA_Parse       ; bool - enable usage of ParseMidi().
  270.                             ; Default is FALSE.
  271.  
  272.     EITEM   CMA_Alarm       ; bool - enable usage of SetMidiAlarm().
  273.                             ; Also allocates mi_AlarmSigBit.  Default is FALSE.
  274.  
  275.     EITEM   CMA_SendPort    ; int - initial SendPort.  Default is CMP_Out(0).
  276.  
  277.     EITEM   CMA_PortFilter  ; int - initial PortFilter.  Default is 0.
  278.  
  279.     EITEM   CMA_TypeFilter  ; int - initial TypeFilter.  Default is 0.
  280.  
  281.     EITEM   CMA_ChanFilter  ; int - initial ChanFilter.  Default is 0.
  282.  
  283.     EITEM   CMA_SysExFilter ; packed - initial SysExFilter as returned by one
  284.                             ; of the PackSysExFilterN() macros. Default is no
  285.                             ; filtering (i.e. recv all).
  286.  
  287.     EITEM   CMA_ErrFilter   ; int - initial ErrFilter.  Default is 0.
  288.         endc
  289.  
  290. ****************************************************************
  291. *
  292. *   MIDI Message Type Bits
  293. *
  294. *   Returned by MidiMsgType() and used with SetMidiFilters().
  295. *
  296. ****************************************************************
  297.  
  298.     BITDEF  CM,Note,0
  299.     BITDEF  CM,Prog,1
  300.     BITDEF  CM,PitchBend,2
  301.  
  302.     BITDEF  CM,CtrlMSB,3
  303.     BITDEF  CM,CtrlLSB,4
  304.     BITDEF  CM,CtrlSwitch,5
  305.     BITDEF  CM,CtrlByte,6
  306.     BITDEF  CM,CtrlParam,7
  307.     BITDEF  CM,CtrlUndef,8      ; for future ctrl # expansion
  308.  
  309.     BITDEF  CM,Mode,9
  310.     BITDEF  CM,ChanPress,10
  311.     BITDEF  CM,PolyPress,11
  312.  
  313.     BITDEF  CM,RealTime,12
  314.     BITDEF  CM,SysCom,13
  315.     BITDEF  CM,SysEx,14
  316.  
  317.     ; some handy type macros
  318.  
  319. CMF_Ctrl    equ CMF_CtrlMSB!CMF_CtrlLSB!CMF_CtrlSwitch!CMF_CtrlByte!CMF_CtrlParam!CMF_CtrlUndef
  320. CMF_Channel equ CMF_Note!CMF_Prog!CMF_PitchBend!CMF_Ctrl!CMF_Mode!CMF_ChanPress!CMF_PolyPress
  321. CMF_All     equ CMF_Channel!CMF_RealTime!CMF_SysCom!CMF_SysEx
  322.  
  323.  
  324. ****************************************************************
  325. *
  326. *   SysExFilter modes
  327. *
  328. *   Contents of sxf_Mode.
  329. *
  330. ****************************************************************
  331.  
  332. SXF_ModeBits    equ $04
  333. SXF_CountBits   equ $03
  334.  
  335. SXFM_Off        equ $00     ; don't filter
  336. SXFM_1Byte      equ $00     ; match upto 3 1-byte id's
  337. SXFM_3Byte      equ $04     ; match a single 3-byte id
  338.  
  339.  
  340. ****************************************************************
  341. *
  342. *   MIDI Error Flags
  343. *
  344. *   These are error flags that can arrive at a MidiNode.
  345. *   An application may choose to ignore or process any
  346. *   combination of error flags.  See SetMidiErrFilter() and
  347. *   GetMidiErr() for more information.
  348. *
  349. ****************************************************************
  350.  
  351.     BITDEF  CME,MsgErr,0        ; invalid message was sent
  352.     BITDEF  CME,BufferFull,1    ; MidiBuffer is full
  353.     BITDEF  CME,SysExFull,2     ; SysExBuffer is full
  354.     BITDEF  CME,ParseMem,3      ; sys/ex memory allocation failure during parse
  355.     BITDEF  CME,RecvErr,4       ; serial receive error
  356.     BITDEF  CME,RecvOverflow,5  ; serial receive buffer overflow
  357.     BITDEF  CME,SysExTooBig,6   ; Attempt to send a sys/ex message bigger than SysExBuffer
  358.  
  359.     ; a handy macro for SetMidiErrFilter()
  360. CMEF_All    equ CMEF_MsgErr!CMEF_BufferFull!CMEF_SysExFull!CMEF_SysExTooBig!CMEF_ParseMem!CMEF_RecvErr!CMEF_RecvOverflow
  361.  
  362.  
  363. ****************************************************************
  364. *
  365. *   CreateMidi() Error Codes
  366. *
  367. *   These are the IoErr() codes that CreateMidi() can return
  368. *   on failure.
  369. *
  370. ****************************************************************
  371.  
  372. CME_NoMem       equ 801         ; memory allocation failed
  373. CME_NoSignals   equ 802         ; signal allocation failed
  374. CME_NoTimer     equ 803         ; timer (CIA) allocation failed
  375. CME_BadPrefs    equ 804         ; badly formed midi.prefs file
  376.  
  377. CME_NoUnit      equ 820         ; unit open failure (really CME_NoUnit + unit num)
  378.  
  379.  
  380. ****************************************************************
  381. *
  382. *   Hook Message ID's
  383. *
  384. *   Each Hook passes as the "msg" param a pointer to one of these (LONG)
  385. *   Can be extended for some types of messages
  386. *
  387. ****************************************************************
  388.  
  389.     ENUM
  390.     EITEM   CMSG_Recv           ; receive MIDI message
  391.     EITEM   CMSG_Link           ; a linkage notification
  392.     EITEM   CMSG_StateChange    ; change timer state
  393.     EITEM   CMSG_Alarm          ; timer alarm
  394.  
  395.  
  396. ***************************************************************
  397. *
  398. *   ClusterNotifyNode
  399. *
  400. ***************************************************************
  401.  
  402.     STRUCTURE ClusterNotifyNode,MLN_SIZE
  403.         APTR    cnn_Task
  404.     BYTE    cnn_SigBit
  405.         STRUCT    cnn_pad,3
  406.     LABEL    ClusterNotifyNode_Size
  407.  
  408. ****************************************************************
  409. *
  410. *   CAMD Macros
  411. *
  412. *   All macros assume A6 = CamdBase.  See camd.doc for more
  413. *   info.
  414. *
  415. ****************************************************************
  416.  
  417. * ---- MidiNode
  418.  
  419. PackSysExFilterN macro  ; Dn, id1, id2, id3
  420.         iflt    narg-1
  421.         fail    PackSysExFilterN -- not enough args
  422.         endc
  423.  
  424.         ifgt    narg-4
  425.         fail    PackSysExFilterN -- too many args
  426.         endc
  427.  
  428. sxf\@_val set   (SXFM_1Byte!(narg-1))<<24
  429.         ifge    narg-2
  430. sxf\@_val set   sxf\@_val!(\2)<<16
  431.         endc
  432.         ifge    narg-3
  433. sxf\@_val set   sxf\@_val!(\3)<<8
  434.         endc
  435.         ifge    narg-4
  436. sxf\@_val set   sxf\@_val!(\4)
  437.         endc
  438.         move.l  #sxf\@_val,\1
  439.         endm
  440.  
  441. PackSysExFilterX macro  ; Dn, xid
  442.         move.l  #(SXFM_3Byte<<24!\2),\1
  443.         endm
  444.  
  445. ClearSysExFilter macro
  446.         PackSysExFilterN d0
  447.         JSRLIB  SetSysExFilter
  448.         endm
  449.  
  450. SetSysExFilterN macro
  451.         ifle    narg-1
  452.         PackSysExFilterN d0,\1
  453.         endc
  454.         ifeq    narg-2
  455.         PackSysExFilterN d0,\1,\2
  456.         endc
  457.         ifge    narg-3
  458.         PackSysExFilterN d0,\1,\2,\3
  459.         endc
  460.         JSRLIB  SetSysExFilter
  461.         endm
  462.  
  463. SetSysExFilterX macro
  464.         PackSysExFilterX d0,\1
  465.         JSRLIB  SetSysExFilter
  466.         endm
  467.  
  468. ClearSysExBuffer macro
  469.         CLEARA  a1
  470.         CLEAR   d0
  471.         JSRLIB  SetSysExBuffer
  472.         endm
  473.  
  474.  
  475. * ---- Message
  476.  
  477. ; commented out by --DJ
  478. ;PutMidi macro
  479. ;       move.l  mm_Msg(a1),d0
  480. ;       move.b  mi_SendPort(a0),d0
  481. ;       JSRLIB  PutMidiToPort
  482. ;       endm
  483. ;
  484. ;PutSysEx macro
  485. ;       move.b  mi_SendPort(a0),d0
  486. ;       move.l  a1,a0
  487. ;       JSRLIB  PutSysExToPort
  488. ;       endm
  489.  
  490.  
  491. * ---- Unit
  492.  
  493. GetMidiInPort macro
  494.         moveq   #-1,d1
  495.         JSRLIB  SetMidiInPort
  496.         endm
  497.  
  498. GetMidiOutMask macro
  499.         move.l  d2,-(sp)
  500.         moveq   #0,d1
  501.         moveq   #0,d2
  502.         JSRLIB  SetMidiOutMask
  503.         move.l  (sp)+,d2
  504.         endm
  505.  
  506.  
  507. * ---- Timer
  508.  
  509. ClearMidiAlarm macro
  510.         moveq   #0,d0
  511.         JSRLIB  SetMidiAlarm
  512.         endm
  513.  
  514.     endc
  515.